summaryrefslogtreecommitdiff
path: root/src/pages/micro/[...page].astro
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-07-03 13:09:53 +0300
committerDawid Rycerz <dawid@rycerz.xyz>2025-07-03 13:09:53 +0300
commit1e5f5a953588cefa75396454c9aed0a79552db14 (patch)
tree733c5bcf71f009acc0bacfbc2269404330c82b5d /src/pages/micro/[...page].astro
parent0bedb68753e7202326383fd10f7af563d7fbc24a (diff)
Migrate notes to micro
Diffstat (limited to 'src/pages/micro/[...page].astro')
-rw-r--r--src/pages/micro/[...page].astro63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/pages/micro/[...page].astro b/src/pages/micro/[...page].astro
new file mode 100644
index 0000000..08f5fd3
--- /dev/null
+++ b/src/pages/micro/[...page].astro
@@ -0,0 +1,63 @@
+---
+import { type CollectionEntry, getCollection } from "astro:content";
+import Pagination from "@/components/Paginator.astro";
+import Note from "@/components/note/Note.astro";
+import PageLayout from "@/layouts/Base.astro";
+import { collectionDateSort } from "@/utils/date";
+import type { GetStaticPaths, Page } from "astro";
+import { Icon } from "astro-icon/components";
+
+export const getStaticPaths = (async ({ paginate }) => {
+ const MAX_MICRO_PER_PAGE = 10;
+ const allMicro = await getCollection("note");
+ return paginate(allMicro.sort(collectionDateSort), { pageSize: MAX_MICRO_PER_PAGE });
+}) satisfies GetStaticPaths;
+
+interface Props {
+ page: Page<CollectionEntry<"note">>;
+ uniqueTags: string[];
+}
+
+const { page } = Astro.props;
+
+const meta = {
+ description: "Read my collection of micro posts",
+ title: "Micro",
+};
+
+const paginationProps = {
+ ...(page.url.prev && {
+ prevUrl: {
+ text: "← Previous Page",
+ url: page.url.prev,
+ },
+ }),
+ ...(page.url.next && {
+ nextUrl: {
+ text: "Next Page →",
+ url: page.url.next,
+ },
+ }),
+};
+---
+
+<PageLayout meta={meta}>
+ <section>
+ <h1 class="title mb-6 flex items-center gap-3">
+ Micro <a class="text-accent" href="/micro/rss.xml" target="_blank">
+ <span class="sr-only">RSS feed</span>
+ <Icon aria-hidden="true" class="h-6 w-6" focusable="false" name="mdi:rss" />
+ </a>
+ </h1>
+ <ul class="mt-6 space-y-8 text-start">
+ {
+ page.data.map((note) => (
+ <li class="">
+ <Note note={note} as="h2" isPreview />
+ </li>
+ ))
+ }
+ </ul>
+ <Pagination {...paginationProps} />
+ </section>
+</PageLayout>